package com.yang.controller.admin;

import com.yang.bean.MarketTopic;
import com.yang.bean.common.BasePageInfo;
import com.yang.bean.common.BaseRespVo;
import com.yang.bean.common.CommonData;
import com.yang.bean.szy.BatchDeleteBO;
import com.yang.bean.szy.QueryTopicVo;
import com.yang.service.admin.AdminTopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("admin/topic")
public class AdminTopicController {
    @Autowired
    AdminTopicService adminTopicService;

    @RequestMapping("list")
    public BaseRespVo<CommonData<MarketTopic>> queryAllTopic(BasePageInfo info,String title,String subtitle) {
        BaseRespVo<CommonData<MarketTopic>> baseRespVo = adminTopicService.queryAllTopic(info,title,subtitle);
        return baseRespVo;
    }

    @RequestMapping("create")
    public BaseRespVo<MarketTopic> createTopic(@RequestBody MarketTopic marketTopic) {
        BaseRespVo<MarketTopic> baseRespVo=adminTopicService.createTopic(marketTopic);
        return baseRespVo;
    }

    @RequestMapping("read")
    public BaseRespVo queryTopic(Integer id) {
        QueryTopicVo data = adminTopicService.queryTopic(id);
        return BaseRespVo.ok(data);
    }
    @RequestMapping("update")
    public BaseRespVo<MarketTopic> updateTopic(@RequestBody MarketTopic marketTopic){
        BaseRespVo<MarketTopic> baseRespVo=adminTopicService.updateTopic(marketTopic);
        return baseRespVo;
    }

    @RequestMapping("delete")
    public BaseRespVo deleteTopic(@RequestBody MarketTopic marketTopic){
        adminTopicService.deleteTopic(marketTopic);
        return BaseRespVo.ok();
    }
    @RequestMapping("batch-delete")
    public BaseRespVo batchDelete(@RequestBody BatchDeleteBO batchDeleteBO){
        adminTopicService.deleteTopics(batchDeleteBO);
        return BaseRespVo.ok();
    }

}
